<template>
    <el-cascader
        v-model="formData[$attrs.prop]"
        v-bind="$attrs"
        :placeholder="placeholder"
        :clearable="clearable"
        @change="doChange"
        @focus="doFocus"
        @remove-tag="doRemoveTag"
    ></el-cascader>
</template>

<script>
export default {
    props: {
        formData: {
            type: Object,
            default: () => ({})
        },
        onChange: {
            type: [Function, undefined],
            default: undefined
        },
        onFocus: {
            type: [Function, undefined],
            default: undefined
        },
        onRemoveTag: {
            type: [Function, undefined],
            default: undefined
        },
        placeholder: {
            type: String,
            default: '请选择'
        },
        clearable: {
            type: Boolean,
            default: true
        }
    },
    methods: {
        doChange(e) {
            if (this.onChange) {
                this.onChange(e)
            }
        },
        doFocus(e) {
            if (this.onFocus) {
                this.onFocus(e)
            }
        },
        doRemoveTag(e) {
            if (this.onRemoveTag) {
                this.onRemoveTag(e)
            }
        }
    }
}
</script>

<style></style>
